<div class="row-fluid">
    <div class="span12">

        <!-- ** widget ** -->
        <div class="well">

            <!-- ** widget header ** -->
            <div class="navbar navbar-heading">
                <div class="navbar-inner">
                    <div class="container" style="width: auto;">
                        <a class="brand" >List Resources Missing</a>
                    </div>
                </div>
            </div>
            <!-- ** ./ widget header ** -->
            {% if resource_missing|length > 0 %}
                        <table class="table">
				<tr>
					<th width="100">Module</th>
					<th width="100">Controller</th>
					<th width="100">Action</th>
					<th width="50">Actions</th>
				</tr>
                                {% for resource in resource_missing %}
				<tr>
                                    <td>{{resource.module}}</td>
                                    <td>{{resource.controller}}</td>
                                    <td>{{resource.action}}</td>
                                    <td><button class="btn btn-mini btn-primary" onClick="addResource('{{resource.module}}','{{resource.controller}}','{{resource.action}}');">Add</button></td>
				</tr>
                                {% endfor %}
			</table>
            {% else %}
            No resut
            {% endif %}

        </div>
        <!-- ** ./ widget ** -->

    </div>
</div>

<script>
    function addResource(module, controller, action)
    {
        $.ajax({
            url: '/backend/acl/addresource',
            type: 'POST',
            data: {module_name: module, controller_name: controller, action_name: action},
            success: function (result, status){
                if (result.message == 'success' ) {
                    location.reload();
                } else {
                    bootbox.alert(result.message);
                }
            }
        });
    }

</script>